package models

import (
	"time"

	"github.com/beego/beego/v2/client/orm"
	_ "github.com/go-sql-driver/mysql" // import your used driver
)

// 用户信息sysUser
type SysUser struct {
	Id          int       `orm:"column(user_id);pk;auto"`
	DeptId      int       `orm:"column(dept_id)"`
	Username    string    `orm:"column(user_name);size(30);unique"`
	NickName    string    `orm:"column(nick_name);size(30)"`
	UserType    string    `orm:"column(user_type);size(2);default('00')"`
	Email       string    `orm:"column(email);size(50);unique"`
	Phonenumber string    `orm:"column(phonenumber);size(11)"`
	Sex         string    `orm:"column(sex);size(1);default('0')"`
	Avatar      string    `orm:"column(avatar);size(100)"`
	Password    string    `orm:"column(password);size(100)"`
	Status      string    `orm:"column(status);size(1);default('0')"`
	DelFlag     string    `orm:"column(del_flag);size(1);default('0')"`
	LoginIp     string    `orm:"column(login_ip);size(128)"`
	LoginDate   time.Time `orm:"column(login_date);type(datetime)"`
	CreateBy    string    `orm:"column(create_by);size(64)"`
	CreateTime  time.Time `orm:"column(create_time);type(datetime)"`
	UpdateBy    string    `orm:"column(update_by);size(64)"`
	UpdateTime  time.Time `orm:"column(update_time);type(datetime)"`
	Remark      string    `orm:"column(remark);size(500)"`
}

// 获取用户
func GetSysUser(id int) (SysUser, error) {
	o := orm.NewOrm()
	user := SysUser{Id: id}
	err := o.Read(&user)
	return user, err
}
